package com.yzpass.api.product;

import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.UUID;
@Getter
@Setter
public class ProductDTO {
    private String productId;

    private String productCode;

    private String productName;

    private String note;

    private String createBy;

    private LocalDateTime createTime;

    private String updateBy;

    private LocalDateTime updateTime;

    public static ProductDTO fromProduct(Product product){
        ProductDTO productDTO = new ProductDTO();
        productDTO.setProductId(String.valueOf(product.getProductId()));
        productDTO.setProductCode(product.getProductCode());
        productDTO.setProductName(product.getProductName());
        productDTO.setNote(product.getNote());
        productDTO.setCreateBy(product.getCreateBy());
        productDTO.setCreateTime(product.getCreateTime());
        productDTO.setUpdateBy(product.getUpdateBy());
        productDTO.setUpdateTime(product.getUpdateTime());
        return productDTO;
    }
    public Product toProduct(){
        Product product = new Product();
        product.setProductId(UUID.fromString(this.getProductId()));
        product.setProductCode(this.getProductCode());
        product.setProductName(this.getProductName());
        product.setNote(this.getNote());
        product.setCreateBy(this.getCreateBy());
        product.setCreateTime(this.getCreateTime());
        product.setUpdateBy(this.getUpdateBy());
        product.setUpdateTime(this.getUpdateTime());
        return product;

    }
}
